import request from '@/utils/http'

/**
 * 用户登录API
 * @param params 登录参数
 * @returns Promise
 */
export const loginApi = (params: { email: string; password: string }) => {
  return request.post('/api/auth/login', params)
}

/**
 * 用户注册API
 * @param params 注册参数
 * @returns Promise
 */
export const registerApi = (params: { 
  email: string; 
  password: string; 
  confirmPassword: string; 
  veryCode: string 
}) => {
  return request.post('/api/auth/register', params)
}

/**
 * 发送验证码API
 * @param params 邮箱参数
 * @returns Promise
 */
export const sendVerificationCodeApi = (params: { email: string }) => {
  return request.post('/api/auth/verification-code', params)
}

/**
 * 验证码登录API
 * @param params 验证码登录参数
 * @returns Promise
 */
export const loginWithCodeApi = (params: { email: string; code: string }) => {
  return request.post('/api/auth/login-with-code', params)
}

/**
 * 重置密码API
 * @param params 重置密码参数
 * @returns Promise
 */
export const resetPasswordApi = (params: {
  email: string;
  veryCode: string;
  newPassword: string;
}) => {
  return request.post('/api/auth/password-reset', params)
}

/**
 * 修改密码API
 * @param uid 用户ID
 * @param params 修改密码参数
 * @returns Promise
 */
export const changePasswordApi = (uid: string, params: {
  oldPassword: string;
  newPassword: string;
  comfirmPassword: string;
}) => {
  return request.put(`/api/user/${uid}/password`, params)
}